<?php
   $this->headLink()->prependStylesheet($this->baseUrl('css/screen.css'));
?>
<? if (! empty($this->user)): ?>
<p>
   <a href="<?=$this->url(array('id' => $this->id),
        'ver') ?>" class="no-bottom"><i class='icon-user'></i> Página de <?=$this->user->nome ?></a>
   <? if ($this->mostrarEditar) : ?>
   &nbsp;&nbsp;&nbsp;
   <a href="<?php echo $this->url(array('controller'=>'participante',
         'action'=>'editar'), 'default', true);?>" class="no-bottom">
      <i class='icon-edit'></i> Editar
   </a>
   &nbsp;&nbsp;&nbsp;
   <a href="<?php echo $this->url(array('controller'=>'participante',
         'action'=>'alterar-senha'), 'default', true);?>" class="no-bottom">
      <i class='icon-lock'></i> Alterar Senha
   </a>
   &nbsp;&nbsp;&nbsp;
   <a href="<?php echo $this->url(array('controller'=>'participante',
         'action'=>'certificados'), 'default', true);?>" class="no-bottom">
      <i class='icon-credit-card'></i> Certificados
   </a>
   <? endif; ?>
</p>

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1&appId=336256479809348";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="container">
   <div class="span-13">
      <p>Meu nome é <?=$this->user->nome ?>.</p>
   </div>
   <div class="span-social">
      <!-- twitter button -->
      <? $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'staging'); ?>
      <a href="https://twitter.com/share" class="twitter-share-button"
         data-url="<?=$this->serverUrl() . $this->url(array('id' => $this->id),
           'ver', true) ?>"
           data-text="Página de <?=$this->user->nome ?>"
           data-via="<?=$config->twitter->username ?>"
           data-lang="pt" data-hashtags="<?=$config->twitter->hashtags ?>">Tweetar</a>
      <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
   </div>
   <div class="span-social">   
      <!-- facebook button -->
      <div class="fb-like" data-href="<?=$this->serverUrl() . $this->url(array('id' => $this->id),
           'ver', true) ?>" data-send="false" data-layout="button_count"
           data-width="450" data-show-faces="false"></div>
   </div>
   <div class="span-social">
      <!-- Place this tag in your head or just before your close body tag. -->
      <script type="text/javascript" src="https://apis.google.com/js/plusone.js">
        {lang: 'pt-BR'}
      </script>

      <!-- Place this tag where you want the +1 button to render. -->
      <div class="g-plusone" data-size="medium" data-href="<?=$this->serverUrl() . $this->url(array('id' => $this->id),
           'ver', true) ?>"></div>
   </div>
</div>
<p>
   Sobre mim: <?=$this->user->bio ?>
</p>
<?
// HACK: usuários não devem ter @ no username do twitter, é um caractere implicito
// ao invés disso ele deve ser usado concatenando o @
// TODO: remover todos os @ de usuários da base de dados antes de remover este HACK!
$tw_user = str_replace("@", "", $this->user->twitter);
if (! empty($tw_user)) {
   $twitter = "Me siga no  <a href='https://twitter.com/#!/{$tw_user}'
class='no-bottom' target='_blank'><i class='icon-twitter'></i> Twitter</a>.";
} else {
   $twitter = "Ainda não possuo <a href='https://twitter.com' class='no-bottom' 
      target='_blank'><i class='icon-twitter'></i> Twitter</a>.";
}
?>
<p><?=$twitter ?></p>

   <?
   if (! empty($this->user->slideshare)):
      try {
         $channel = new Zend_Feed_Rss("http://www.slideshare.net/rss/user/{$this->user->slideshare}");
   ?>
<hr/> 
<div class="container">
   <div class="span-6">
      <a href="<? echo $channel->link; ?>" target="_blank">
         <img src="<? echo $channel->image->url; ?>"/>
      </a>
   </div>
   <div class="span-12">
      <h4 style="padding-top: 6px;">Slideshows de
         <a href="<? echo "{$channel->link}{$this->user->slideshare}" ?>" target="_blank">
            <? echo $this->user->slideshare ?>
         </a>
      </h4>
   </div>
   <hr/>
</div>
      <?
      $maxEmbedSlides = 3;
      $i = 0;
      foreach ($channel as $item): ?>
<div class="container">
   <div class="span-20">
      <? if ($i < $maxEmbedSlides): ?>
         <? echo ($item->__get('slideshare:embed')); ?>
      <? else: ?>
      <i class='icon-external-link'></i> <a href="<? echo $item->link; ?>" target="_blank">
         <? echo $item->title; ?></a>
      <? endif; ?>
   </div>
</div><hr/>
      <?
         $i++;
      endforeach; ?>
   <? 
      } catch (Exception $e) {
         ?>
<div class="notice">
   <div class="msg-header">Atenção!</div>
   <div>Usuário do Slideshare <? echo $this->user->slideshare; ?> não encontrado.</div>
   <div>Detalhes: <? echo $e->getMessage(); ?></div>
</div>
         <?
      }
   else: ?>
Crie uma conta no <a href="http://www.slideshare.net/"
                     class="no-bottom" target="_blank">
   <img src="<? echo $this->baseUrl('img/slideshare.png'); ?>"/> Slideshare</a>
para que suas apresentações apareçam aqui.
   <? endif; ?>
<? else: // end: not empty user ?>
<p>Participante não encontrado.</p>
<? endif; ?>